﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

class TitleScreen : MenuScreen
{
    private double initialTime = 0;

    private Texture2D background;

    public TitleScreen() : base()
    {
        TransitionOnTime = TimeSpan.Zero;
        TransitionOffTime = TimeSpan.Zero;
    }

    public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
    {
        if(initialTime == 0)
            initialTime = gameTime.TotalRealTime.TotalMilliseconds;

        if (initialTime + 3000 < gameTime.TotalRealTime.TotalMilliseconds)
            Exit();

        if (InputManager.IsActionTriggered())
            Exit();

        base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
    }

    public override void LoadContent()
    {
        base.LoadContent();

        background = ScreenManager.Game.Content.Load<Texture2D>("Textures/Screen/titlescreen");
    }

    public override void HandleInput()
    {
        if (InputManager.IsActionTriggered())
        {
            Exit();
            return;
        }

        base.HandleInput();
    }

    public override void Draw(GameTime gameTime)
    {
        SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

        spriteBatch.Begin();
        spriteBatch.Draw(background, new Vector2(0, 0), Color.White);
        spriteBatch.End();
    }

    public void Exit()
    {
        ScreenManager.AddScreen(new MainMenuScreen());
        ExitScreen();
    }

}
